﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace QL_KhachHang
{
    public partial class FrmThongkeHd : Form
    {
        public FrmThongkeHd()
        {
            InitializeComponent();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string chuoi = "SELECT*FROM HoaDon WHERE (MONTH(NgayLap)=" + cbthang.Text + ")and (year(NgayLap)=" + cbnam.Text + ")  ";
                SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=E:\nhomqlks\Code\QL_KhachHang\DA\QLKHACHSAN.mdf;Integrated Security=True");
                SqlDataAdapter da = new SqlDataAdapter(chuoi, con);
                DataTable dt = new DataTable();
                da.Fill(dt);
                CRHoaDon cr =new CRHoaDon();
                cr.SetDataSource(dt);
                crystalReportViewer1.ReportSource = cr;
            }
            catch { }

        }

        private void FrmThongkeHd_Load(object sender, EventArgs e)
        {
            try
            {
                string chuoi = "SELECT*FROM HoaDon WHERE (MONTH(NgayLap)=" + cbthang.Text + ")and (year(NgayLap)=" + cbnam.Text + ")  ";
                SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=E:\nhomqlks\Code\QL_KhachHang\DA\QLKHACHSAN.mdf;Integrated Security=True");
                SqlDataAdapter da = new SqlDataAdapter(chuoi, con);
                DataTable dt = new DataTable();
                da.Fill(dt);
                CRHoaDon cr = new CRHoaDon();
                cr.SetDataSource(dt);
                crystalReportViewer1.ReportSource = cr;
            }
            catch { }
        }
    }
}
